#pragma once

#include "../../utils/render_line.h"
#include "../../utils/render_point.h"
#include "../../utils/render_polygon.h"
#include "../../utils/render_ref.h"
#include "qlib/all.h"

namespace qbe::Stretch {

struct SelectInfo {
  entt::entity select_entity;
  std::set<int> select_indexs;
  std::vector<qlib::Vec2d> key_points;
};
struct StretchInfo {
  std::set<int> select_indexs;
  std::vector<qlib::Vec2d> key_points;
};
struct StretchModel {
  double old_x = 0, old_y = 0;

  double origin_x = 0, origin_y = 0;

  std::shared_ptr<utils::TempRender::RenderPolygon> render_polygon;
  std::shared_ptr<utils::TempRender::RenderLine> render_line;
  std::shared_ptr<utils::TempRender::RenderPoint> render_point;

  qlib::Ruler::s_ptr temp_render_ruler;

  bool is_strech = false;
  bool is_init = false;

  bool is_angle_lock = true;

  bool is_left_press = false;

  std::vector<SelectInfo> selects;
  std::vector<entt::entity> sel_entity_all;

  std::map<entt::entity, std::shared_ptr<StretchInfo>> ele_in_selected_points;

  std::map<entt::entity, qlib::Fan::s_ptr> fan_temp_fans;
  std::map<entt::entity, qlib::Ellipse::s_ptr> elli_temp_ellis;

  void reset() {
    old_x = 0;
    old_y = 0;
    origin_x = 0;
    origin_y = 0;
    render_polygon.reset();
    render_line.reset();
    render_point.reset();
    is_strech = false;
    is_init = false;
    is_left_press = false;
    selects.clear();
    sel_entity_all.clear();
    ele_in_selected_points.clear();
    fan_temp_fans.clear();
    elli_temp_ellis.clear();
  }
};
struct TempRulerRenderModel {
  qlib::Ruler::s_ptr temp_ruler;
};

}  // namespace qbe::Stretch